<!DOCTYPE html>
<html lang="zh-CN">

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>登陆</title> 
		
		<!-- Bootstrap -->
		<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}
			
			.class_div_loginbox {
				height: 300px;
				border: 1px solid black;
				margin-top: 10%;
			}
			
			.class_h1_title {
				text-align: center;
			}
		</style>
	</head>

	<body>
		<div class="row">
			<div class="col-xs-4 col-xs-offset-4 class_div_loginbox">
				<div>
					<div>
						<h1 class="class_h1_title">管理员登陆系统</h1>
					</div>
					<form class="form-horizontal" id='loginForm' name="loginForm" onsubmit="return false">
						<div class="form-group">
							<label for="inputEmail3" class="col-sm-2 col-sm-offset-1 control-label">账号：</label>
							<div class="col-sm-8">
								<input type="text" name="username" class="form-control" id="usernmae" placeholder="请输入账号">
							</div>
						</div>
						<div class="form-group">
							<label for="inputPassword3" class="col-sm-2 col-sm-offset-1 control-label">密码：</label>
							<div class="col-sm-8">
								<input type="password" name="password" class="form-control" id="password" placeholder="请输入密码">
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-offset-4 col-sm-4">
								<button class="btn btn-info" style="width:100%;text-align: center;" onclick="Login()">登陆</button>
							</div>
						</div>
					</form>

					</div>
				</div>
			</div>
			<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
			<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
			<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
			<script src="../js/ip.js"></script>
			<script type="text/javascript">
				function Login() {
					var ip = returnIp();
					var postaddress = '/login';
					console.log($('#loginForm').serializeArray());
					$.ajax({
						//几个参数需要注意一下
						type: "POST", //方法类型
						dataType: "json", //预期服务器返回的数据类型
						url: postaddress, //url
						data: $('form').serializeArray(),
						success: function(result) {
							console.log(result); //打印服务端返回的数据 
							if (result.code == 0)
							{
								if(result.data == "ADMIN")
									  window.location.href = 'admin.html';
								  else 
									  window.location.href = 'rater.html'; 
							} 
						}, 
						error: function() {

						}
					});
				}
			</script>
	</body>

</html>